/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DatabaseConnection;

import Entities.Ticket;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author serhat
 */
public class TicketDbConnection extends Connector{
    public TicketDbConnection() throws ClassNotFoundException,
            SQLException, InstantiationException, IllegalAccessException {
        
    }
    
    private String buildInsertQuery(Ticket ticket){
        String query = String.format("INSERT INTO Bilet VALUES"
                + "('%d', '%d', '%f')",
                ticket.getPassenger().getTcKimlik(),
                ticket.getSeat().getSeatId(),
                ticket.getFee());
        return query;
    }
    
    public boolean insert(Ticket ticket){
        try {
            String query = buildInsertQuery(ticket);
            executeUpdate(query);
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(TicketDbConnection.class.getName()).log(Level.SEVERE, null, ex);
            return false;
        }
    }
}
